-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Update to enable tracking id from order to trade #199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This is a simple change to backtesting.py to enable a user to track which trade came from which order (and a lot of other potential benefits) as outlined in issue #197. It simply allows the assignment of an id when creating an order at with `Strategy.buy()` and `Strategy.sell()`. The id is type agnostic, so the user can make it a string, int, float or whatever may be necessary. I could not think of a better way to solve this problem and I will be able to test that this works in the next day or so. I hope people think this is a good idea 😟 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will additionally need a unit test and a good example use for the docs.
backtesting/backtesting.py
Outdated
An ID attribute which, if set, persists to enable tracking of this order | ||
if it becomes a trade in `Strategy.trades` and when closed in `Strategy.closed_trades`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe:
An arbitrary tag object which, if set, propagates to the
Trade
this order started.
Which begs the question, what about orders that close existing trades?
Sorry, I have completely butchered the PR process here. git is driving me a bit nuts. |
Fyi, you can |
😅 sorry, yes I'm in the difficult position of trying to do a lot with a little time at the moment, so your advice is great and something I would normally have googled to self-educate but December is 🤮 haha |
This is a simple change to backtesting.py to enable a user to track which trade came from which order (and a lot of other potential benefits) as outlined in issue #197.
It simply allows the assignment of an id when creating an order at with
Strategy.buy()
andStrategy.sell()
. The id is type agnostic, so the user can make it a string, int, float or whatever may be necessary.I could not think of a better way to solve this problem and I will be able to test that this works in the next day or so. I hope people think this is a good idea 😟 😅